package io.geekidea.boot.inventorychange.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.geekidea.boot.inventorychange.dto.StoreChangeDto;
import io.geekidea.boot.inventorychange.dto.StoreChangeExcel;
import io.geekidea.boot.inventorychange.entity.StoreChange;
import io.geekidea.boot.inventorychange.query.StoreChangeQuery;
import io.geekidea.boot.inventorychange.vo.StoreChangeVo;
import io.geekidea.boot.otherstores.query.total;
import io.geekidea.boot.store.entity.Store;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StoreChangeMapper extends BaseMapper<StoreChange> {

    //库存变动记录
    List<StoreChange> StoreChanagList(StoreChangeQuery storeChangeQuery);

    total getTotal(StoreChangeQuery storeChangeQuery);

    //库存变动类型
    @Select("select distinct sto.typeofchange from tb_storechange sto")
    List<StoreChangeVo> typeList(StoreChangeQuery storeChangeQuery);

    List<StoreChangeExcel> getDownloadList(StoreChangeQuery storeChangeQuery);

    @Select("select id,name from tb_store")
    List<Store> StoreList(StoreChangeQuery storeChangeQuery);

    @Insert("insert into tb_storechange(warehouseentrynumber, materialcode, materialsnmark, nameofmaterial, materialswarehouse, typeofchange, changebehavior, quantityofchange, quantityinstock, availablestock, lockininventory, areaname_fk, storename_fk, odd, createdBy, updatedBy)values (#{warehouseentrynumber},#{materialcode},#{materialsnmark},#{nameofmaterial},#{materialswarehouse},#{typeofchange},#{changebehavior},#{quantityofchange},#{quantityinstock},#{availablestock},#{lockininventory},#{timeofchange},#{areaname_fk},#{storename_fk},#{odd},#{createdBy},#{updatedBy})")
    int addStoreChange(StoreChangeDto storeChangeDto);
}
